function transfer(timeStamp){
	var ymd=new Date();
	ymd.setTime(timeStamp*1000);
	var month=(ymd.getMonth()+1).toString();
	var date=ymd.getDate().toString();
	return month+"-"+date;
}

function change(json,current){
	$(".header li").removeClass("current");
	$(".header "+current).addClass("current");
	//var json=JSON.parse(htmlobj.responseText);
	$("body .content").empty();
	for(var i=0;i<json.length;i++){
		$("body .content").append("<li><small>"+transfer(json[i]["updated"])+"</small><a href='"+json[i]["link"]+"'>"+json[i]["title"]+"</a>("+json[i]["feed_title"]+")</li>");
	}
	$("body a").click(function(){
		chrome.tabs.create({ url: $(this).attr("href") });
	});  
}
var key = 'mytinytinyrss';
var sid = '';
document.addEventListener('DOMContentLoaded', function () {	

	var config = localStorage[key];
	config = config.split(" ");
	url = config[0];
	sid = config[3];
   $(".hot").click(function(){
   		$.post(url, '{"sid":"' +sid + '","op":"getHeadlines", "feed_id":-3, "limit":100, "view_mode":"unread", "order_by":"feed_dates"}',function(data){
	    		change(data["content"],".hot"); 
	  	}, 'json'); 
   });
   $(".hot").click();
  //  $(".new").click(function(){
		// htmlobj=$.ajax({url:"https://www.v2ex.com/api/topics/latest.json",dataType:"json",async:false});
	 //    change(htmlobj,".new"); 
  //  });
   
});
